package com.tvein.sanguo.chat.controller
{
	//flash
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.chat.common.GameConstants;
	import com.tvein.sanguo.chat.view.ChatMediator;
	import com.tvein.sanguo.chat.model.MessageProxy;
//
	public class ChatMsg extends SimpleFabricationCommand implements ICommand
	{
		private var messageProxy:MessageProxy;
		private var chatMediator:ChatMediator;
		
		override public function execute(notification:INotification) : void
		{
			messageProxy = facade.retrieveProxy(MessageProxy.NAME) as MessageProxy;
			chatMediator = facade.retrieveMediator(ChatMediator.NAME) as ChatMediator;
			
			messageProxy.addMessage([String(notification.getBody()[0]), String(notification.getBody()[1]), int(notification.getBody()[2])]);
			
			routeNotification(GameConstants.MODULE_INVOKE, ["-message", [String(notification.getBody()[0]), String(notification.getBody()[1]), int(notification.getBody()[2])]], null, GameConstants.MODULE_ROOM + "/*");
		}
	}
}